package com.urchin.avatarhero;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

/**********************************************************************
AvatarHero - A task management RPG Android Application
Copyright (C) 2013  Peter Clay

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
***********************************************************************/

public class Prefs {

    private static SharedPreferences getPrefs(Context context) {
        return PreferenceManager.getDefaultSharedPreferences(context);
    }

    // Getters
    
    public static String getMyStringPref(Context context, String strpref) {
        return getPrefs(context).getString(strpref, "default");
    }

    public static int getMyIntPref(Context context, String intpref) {
        return getPrefs(context).getInt(intpref, 42);
    }
    
    public static boolean getMyBoolPref(Context context, String boolpref) {
        return getPrefs(context).getBoolean(boolpref, true);
    }

    // Setters
    
    public static void setMyStringPref(Context context, String value, String strpref) {
        // perform validation etc..
        getPrefs(context).edit().putString(strpref, value).commit();
    }

    public static void setMyIntPref(Context context, int value, String intpref) {
        // perform validation etc..
        getPrefs(context).edit().putInt(intpref, value).commit();
    }

    public static void setMyBoolPref(Context context, boolean value, String boolpref) {
        // perform validation etc..
        getPrefs(context).edit().putBoolean(boolpref, value).commit();
    }
}
